package cn.evolify.jfinaldemo.interceptor;

import cn.evolify.jfinaldemo.base.R;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

/**
 * Created by wolf on 2017/2/21.
 **/
public class UserInterceptor implements Interceptor {
    public void intercept(Invocation invocation) {
        Controller controller=invocation.getController();
        if (controller.getSessionAttr(R.SessionKey.USER)==null){
            controller.redirect("/user/login");
        }else{
            invocation.invoke();
        }
    }
}
